import {defineConfig} from "vite";
import vue from "@vitejs/plugin-vue";
import legacy from "@vitejs/plugin-legacy";
import {resolve} from "path";
import autoprefixer from 'autoprefixer';
import postCssPxToRem from 'postcss-pxtorem';
// https://vitejs.dev/config/
export default defineConfig({
    plugins: [vue(), legacy({
        targets: ["> 1%, last 1 version, ie >= 11"], additionalLegacyPolyfills: ["regenerator-runtime/runtime"],
    }),], css: {
        postcss: {
            plugins: [autoprefixer({
                overrideBrowserslist: ["Android 4.1", "iOS 7.1", "Chrome > 31", "ff > 31", "ie >= 8",],
            }), postCssPxToRem({
                // 自适应，px>rem转换
                rootValue: 37.5, // 75表示750设计稿，37.5表示375设计稿
                propList: ["*"], // 需要转换的属性，这里选择全部都进行转换
                selectorBlackList: ["norem"], // 过滤掉norem-开头的class，不进行rem转换
            }),],
        },
    }, resolve: {
        alias: {
            "@": resolve(__dirname, ".", "src"),
        }, // 忽略后缀名的配置选项, 添加 .vue 选项时要记得原本默认忽略的选项也要手动写入
        extensions: [".mjs", ".js", ".ts", ".jsx", ".tsx", ".json", ".vue"],
    }, server: {
        open: true, port: 3333,
    },

    build: {
        target: "es2015",
    },
});
